//
//  FirstPageViewController.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/8.
//

#import "FirstPageViewController.h"
#import "FirstPageHeadView.h"
#import "FirstPageMiddleView.h"
#import "FirstPageBottomView.h"

//完善教练资料
#import "CompleteCoachingProfilesViewController.h"
//我的约课
#import "StudentClassSureViewController.h"

//招生名片
#import "AdmissionsCardViewController.h"
//更多素材
#import "MoreMaterialViewController.h"

//保存图片
#import "SavePhotoImageViewController.h"
//微信头像
#import "WechatAvatarViewController.h"
//今日约课
#import "NowClassListViewController.h"


@interface FirstPageViewController ()
{
    UIScrollView *_ScrollView;
    
    FirstPageHeadView *_FirstPageHeadView;
    FirstPageMiddleView *_FirstPageMiddleView;
    FirstPageBottomView *_FirstPageBottomView;
}
@end

@implementation FirstPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    

    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *headImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 120)];
    headImg.backgroundColor = [UIColor whiteColor];
    headImg.image = [UIImage imageNamed:@"HeadImg"];
    headImg.layer.cornerRadius = 125/2;
    headImg.userInteractionEnabled = YES;
    [self.view addSubview:headImg];
    
    //隐藏头部view
    self.navigationController.navigationBar.hidden = YES;
    NavigationHeadView *navgationheadv = [[NavigationHeadView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, SafeAreaTopHight)];
    navgationheadv.backgroundColor = [UIColor clearColor];
    navgationheadv.backbtn.hidden = YES;
    navgationheadv.titlelabel.text = @"教练宝典";
    [self.view addSubview:navgationheadv];

    
    _ScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, APPheight)];
    _ScrollView.contentSize = CGSizeMake(APPwidth,APPheight*2);
//    _ScrollView.backgroundColor = rgba(244, 247, 252, 1);
    _ScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    _ScrollView.bounces = true; // 表明当前滑动是否有反弹效果
    _ScrollView.pagingEnabled = NO; // 分页效果
    _ScrollView.showsVerticalScrollIndicator = NO;
    _ScrollView.scrollEnabled = true; // 使当前能够滑动和不能滑动
    [self.view addSubview:_ScrollView];


    _FirstPageHeadView = [[FirstPageHeadView alloc]initWithFrame:CGRectMake(0, 40, APPwidth, 360)];
    [_ScrollView addSubview:_FirstPageHeadView];
    [_FirstPageHeadView.PleaseLoginBtn addTarget: self action:@selector(PleaseLoginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    //我的约课
    [_FirstPageHeadView.myClassBtn addTarget:self action:@selector(myClassBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    //今日约课
    [_FirstPageHeadView.todayClassBtn addTarget:self action:@selector(todayClassBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    _FirstPageMiddleView = [[FirstPageMiddleView alloc]initWithFrame:CGRectMake(0, _FirstPageHeadView.frame.size.height+_FirstPageHeadView.frame.origin.y, APPwidth, 460)];
    [_ScrollView addSubview:_FirstPageMiddleView];
    
    [_FirstPageMiddleView.admissionsServicesBtn addTarget:self action:@selector(admissionsServicesBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_FirstPageMiddleView.wechatAvatarBtn addTarget:self action:@selector(wechatAvatarBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
    
    
    
    
    
    _FirstPageBottomView = [[FirstPageBottomView alloc]initWithFrame:CGRectMake(0, _FirstPageMiddleView.frame.size.height + _FirstPageMiddleView.frame.origin.y, APPwidth, 420)];
    [_ScrollView addSubview:_FirstPageBottomView];
    //更多
    [_FirstPageBottomView.moreBtn addTarget:self action:@selector(moreBtnClick) forControlEvents:UIControlEventTouchUpInside];
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pictureClick:)];
    gesture.numberOfTapsRequired = 1;
    [_FirstPageBottomView.textView addGestureRecognizer:gesture];
    
}
#pragma mark - 完善教练资料
-(void)PleaseLoginBtnClick{
    CompleteCoachingProfilesViewController *vc = [[CompleteCoachingProfilesViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - 我的约课
-(void)myClassBtnClick{
    
    StudentClassSureViewController *vc = [[StudentClassSureViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - 今日约课
-(void)todayClassBtnClick{
    NowClassListViewController *vc = [[NowClassListViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}


#pragma mark - 招生名片
-(void)admissionsServicesBtnClick{
    AdmissionsCardViewController *vc = [[AdmissionsCardViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}

#pragma mark - 微信头像
-(void)wechatAvatarBtnClick{
    WechatAvatarViewController *vc = [[WechatAvatarViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}












#pragma mark - 更多素材
-(void)moreBtnClick{
    MoreMaterialViewController *vc = [[MoreMaterialViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 图片点击
-(void)pictureClick:(UIImage *)img{
    SavePhotoImageViewController *vc = [[SavePhotoImageViewController alloc]init];
    vc.img = _FirstPageBottomView.pictureImgv.image;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark -视图即将出现
-(void)viewWillAppear:(BOOL)animated{
        
    ((TabbarController *)self.tabBarController).tabBarView.hidden = NO;
    
}

@end
